package cn.java75.printer2;

/**
 * @author oldliu
 * @since 1.0
 */
public class TextPaper {
    private int lineWords;
    private int lines;
    public void print(String str){
        char cr[]=str.toCharArray();
        int w=0;//当前行打印的字数
        int l=0;//当前页打印了几行
        int page=1;
        for(char c:cr){
            System.out.print(c);
            w++;
            if(w==lineWords){
                System.out.println();
                l++;
                w=0;
                if(l==lines){
                    System.out.println("---"+(page++)+"----");
                    l=0;
                }
            }
        }
        if(w!=0||l!=0){
            System.out.println("\n---"+(page++)+"----");
        }
    }

    public int getLineWords() {
        return lineWords;
    }

    public void setLineWords(int lineWords) {
        this.lineWords = lineWords;
    }

    public int getLines() {
        return lines;
    }

    public void setLines(int lines) {
        this.lines = lines;
    }
}
